package com.hippo.spring.controller;

import com.hippo.spring.pojo.User;
import com.hippo.spring.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/save")
    @ResponseBody
    public User save(){
        return userService.save();
    }

    @RequestMapping("/hello")
    public String hello(HttpServletRequest request){
        User user = userService.save();
        request.setAttribute("user",user);
        return "hello";
    }
}
